package zhan.interceptor;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import zhan.common.Constants;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 公共参数拦截器
 */
public class CommonDataInterceptor extends HandlerInterceptorAdapter {
    public static final Logger log = Logger.getLogger(CommonDataInterceptor.class);
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String path = request.getScheme() + "://" +
                      request.getServerName() +":"+
                      request.getServerPort() +
                      request.getContextPath();
        log.info("---->公共参数拦截器-----#########CommonDataInterceptor########"+"path=" + path);
        request.setAttribute(Constants.CONTANTS_PATH, path);
        return super.preHandle(request, response, handler);
    }
}
